#
# @lc app=leetcode.cn id=53 lang=python
#
# [53] 最大子数组和
#

# @lc code=start
class Solution(object):
    def maxSubArray(self, nums):
        """
        :type nums: List[int]
        :rtype: int
        """
        sum_result = float('-inf')
        cur = 0
        for i in range(len(nums)):
            cur += nums[i]
            if cur > sum_result:
                sum_result = cur

            if cur <= 0:
                cur = 0
        return sum_result
        
        
# @lc code=end

